//
//  SYYMarcos.h
//  NineteenBook
//
//  Created by xhkj on 2021/8/2.
//  Copyright © 2021 58阅读. All rights reserved.
//

#ifndef SYYMarcos_h
#define SYYMarcos_h

/**
 * ===尺寸===
 */

#define isX [UIView isIphoneX]


#define ScreenWidth  ([UIScreen mainScreen].bounds.size.width)
#define ScreenHeight ([UIScreen mainScreen].bounds.size.height)

#define StatusBarHeight   [UIView statusBarHight]
#define NavBottomHeight   [UIView naviBarHight]
#define NavBarHeight      (StatusBarHeight+NavBottomHeight)
#define TabBarHeight      [UIView tarBarHight]
#define BottomSafeHeight  [UIView safeBottomBarHight]



#define SearchViewHeight         45.0
#define BannerViewHeight         ((ScreenWidth - 25) * 170 / 350.0)
#define FileCategoryViewHeight   92.0



//navbar subViews
#define ItemBtnSpace  10.0
#define ItemBtnWidth  44.0
#define ItemBtnHeight 44.0
#define NavTitleLabelWidth (ScreenWidth - (ItemBtnSpace  + ItemBtnWidth) * 2)


#define LeftSpace  ScreenWidth/10.0
#define RightSpace -ScreenWidth/10.0


#define PageSize 10



/**
 * ===NSUserDefaults ===
 */

#define SetUserDefaults(value,key) [[NSUserDefaults standardUserDefaults] setObject:value forKey:key]
#define GetUserDefaults(key)       [[NSUserDefaults standardUserDefaults] objectForKey:key]
#define RemoveUserDefaults(key)    [[NSUserDefaults standardUserDefaults] removeObjectForKey:key]


//网络状态
#define NetWorkingState      @"NetWorkingState"
#define NetWorkingState_WIFI @"NetWorkingState_WIFI"
#define NetWorkingState_GPES @"NetWorkingState_GPES"
#define NetWorkingState_NULL @"NetWorkingState_NULL"
#define GET_NetWorkingState  [[NSUserDefaults standardUserDefaults] objectForKey:NetWorkingState]
#define NetWorkingStateChangeWIFI      @"NetWorkingStateChangeWIFI"
#define NetWorkingStateChangeGPES      @"NetWorkingStateChangeGPES"
#define NetWorkingStateChangeNULL      @"NetWorkingStateChangeNULL"


#define NAME        @"name"

#define LOGINKEY                  @"loginkey"
#define SET_LOGINKEY(loginKeyStr) SetUserDefaults(loginKeyStr,LOGINKEY)
#define GET_LOGINKEY              GetUserDefaults(LOGINKEY)

#define CELLPHONE   @"cellphone"
#define SET_CELLPHONE(cellphoneStr) SetUserDefaults(cellphoneStr,CELLPHONE)
#define GET_CELLPHONE               GetUserDefaults(CELLPHONE)

#define PASSWORD    @"password"
#define SET_PASSWORD(passwordStr) SetUserDefaults(passwordStr,PASSWORD)
#define GET_PASSWORD              GetUserDefaults(PASSWORD)

#define USERID         [NSString stringWithFormat:@"userId%@",GET_CELLPHONE]
#define SET_USERID(ID) SetUserDefaults(ID,USERID)
#define GET_USERID     GetUserDefaults(USERID)?GetUserDefaults(USERID):@"0"



/**
 * ===Others===
 */

#define LibBundle [NSBundle bundleWithURL:[[NSBundle bundleForClass:[self class]] URLForResource:@"libName" withExtension:@"bundle"]]




#define NullImage       @"nullImage"
#define HTTP_ERROR_INFO @"未能连接到服务器。"




#define WeakSelf  __weak typeof(self)weakSelf = self;
#define StrongSelf(var) __strong typeof(var) strongSelf = var;



#ifndef __OPTIMIZE__
#define NSLog(...) NSLog(__VA_ARGS__)
#else
#define NSLog(...){}
#endif



#define DEF_SINGLETON(className) \
\
+ (className *)sharedInstance;

#define IMP_SINGLETON(className) \
\
+ (className *)sharedInstance { \
static className *sharedInstance = nil; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
sharedInstance = [[self alloc] init]; \
}); \
return sharedInstance; \
}



#endif /* SYYMarcos_h */
